package ru.gelin.android.keyboard;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.inputmethod.InputMethodManager;

import static ru.gelin.android.keyboard.Tag.TAG;

public class DockEventReceiver extends BroadcastReceiver {
    
    public void onReceive(Context context, Intent intent) {
        MainPreferences preferences = new MainPreferences(context);
        if (!preferences.isOnDockListen()) {
            return;
        }

        int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED);
        String msg = "DOCK: " +
                (state == Intent.EXTRA_DOCK_STATE_UNDOCKED ? "undocked" : "docked");
        Log.d(TAG, msg);
        //Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
        InputMethodManager manager = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.showInputMethodPicker();
    }

}
